import Vue from 'vue'
import VueRouter from 'vue-router'

//1.注入插件
Vue.use(VueRouter)

import App  from '@/App.vue'
    import Adm  from '@/views/Adm.vue'
        import Img  from '@/views/adm/imgg.vue'
        import Book from "@/views/adm/book/Book.vue"
            import Add from "@/views/adm/book/add.vue"
        import Type from "@/views/adm/type/Type.vue"
        import Type93 from "@/views/adm/type/Type93.vue"
        import Hot  from "@/views/adm/hot/Hot.vue"
            import HotAdd from "@/views/adm/hot/add.vue"
        import Order from "@/views/adm/order/Order.vue"
        import UserList from "@/views/adm/user/UserList.vue"
        import AddUser from "@/views/adm/user/AddUser.vue"
        import UserOrders from "@/views/adm/user/UserOrders.vue"

    import Fore from '@/views/Fore.vue'
        import Cart from "@/views/fore/cart/Cart.vue"
            import Payment from "@/views/fore/cart/Payment.vue"
        import Details from "@/views/fore/details/Details.vue"
        import Home  from "@/views/fore/home/Home.vue"
        import OrderInfo  from "@/views/fore/order/OrderInfo.vue"
            import GoOrders from "@/views/fore/order/GoOrders.vue"
        import UserInfo from "@/views/fore/UserInfo.vue"
        import Register from "@/views/fore/Register.vue"


//2.定义路由
const routes = [

    //打开浏览器跳转到首页
    {   path: '/',redirect: '/home' , component:App },
	
    //进入后端,默认显示类型管理组件
    {   path: '/adm', redirect: '/def'},

    //后端页面
    {   path: "/adm",
        component:Adm,
        children:[
            //书本管理组件
            { path: "book/book",  component:Book},
            //书本添加和修改一体组件
            { path: "book/add",   component:Add},
            //类型管理组件
            { path: "type/type",  component:Type},
            //类型管理组件
            { path: "type/type93",  component:Type93},
            //进入后台管理默认显示类型管理组件
            { path: "/def", component:Img },
            //热点管理组件
            { path: "hot/hot", component:Hot},
            //热点添加组件
            { path: "hot/add", component:HotAdd},
            //订单发货组件
            { path: "order/shipments", component:Order},
            //用户列表组件
            { path: "user/userList", component:UserList},
            //管理员添加组件
            { path: "user/addUser", component:AddUser},
            //某个用户的订单组件
            { path: "user/userOrders", component:UserOrders},
        ]
    },

    //前端页面
    {   path: "/fore",
        component:Fore,
        children:[
             //商品详情组件
            { path: "details/details", component:Details },
             //购物车组件
            { path: "cart/cart",    component:Cart},
             //主页组件
            { path: "home/home",  component:Home},
            //订单组件
            { path: "order/order",  component:OrderInfo},
             //下单组件
            { path: "order/GoOrders",  component:GoOrders},
             //付款组件
            { path: "order/Payment",  component:Payment},
            //重定向到主页
            { path: "/home", component:Home },
            //个人信息组件
            { path: "UserInfo",  component:UserInfo},
            //注册组件
            { path: "Register",  component:Register},
        ]
    }

]

//3.创建routes实例
const router = new VueRouter({
    routes
})

//导出routes实例
export default router